<?
if(isset($_REQUEST["iUnit"]))
switch (strtolower($_REQUEST["iUnit"])){
    
    case "loadorder":
        include "../H/OrderDetail.php";
        break;
    case "addtocart":
    
        $id		=isset($_REQUEST["id"])?($_REQUEST["id"]):null;
        $item=array("id"=>$id,"sl"=>1);
        if(isset($_SESSION["yourcart"])){
            $carts=$_SESSION["yourcart"];
            $flag=true;
            for($i=0;$i<count($carts); $i++){
                $c=$carts[$i];
                if($c["id"]==$item["id"]){
                    $carts[$i]["sl"]++;
                    $flag=false;
                }
            }
            if($flag){
               array_push($carts,$item); 
            }
            $_SESSION["yourcart"]=$carts;
        }else{
            $carts=array();
            array_push($carts,$item);
            $_SESSION["yourcart"]=$carts;
        }
        //print_r($_SESSION["yourcart"]);
        echo "true";
        break;
    case "removetocart":
        
        $id		=isset($_REQUEST["id"])?($_REQUEST["id"]):null;
        if(isset($_SESSION["yourcart"])){
            $carts=$_SESSION["yourcart"];
            for($i=0;$i<count($carts); $i++){
                $c=$carts[$i];
                if($c["id"]==$id){
                    $carts[$i]["sl"]--;
                }
            }
            $_SESSION["yourcart"]=$carts;
        }
        echo "true";
        break;
    case "loadcartnum":
        $carts=$_SESSION["yourcart"];
        $sl=0;
        foreach($carts as $c){
            if($c["sl"]>0){
                $sl++;
            }
        }
        echo $sl;
        break;
    case "loadyourcart":
        include "../H/Cart2.php";
        break;
    case "loadconfirmorder":
        include "../H/Order.php";
        break;
    default :
        echo '
                <div style="padding:0 20px">
                <div id="mini_inner" class="centered">
                <img src="../images/images (2).jpg" alt="" height="50" class="alert">
                <h1><strong>Error 404:</strong>Oh no! We couldn\'t find your page.</h1>
                <p>This page may not exist anymore, or the URL may have been misspelled. Either way, we are sorry. 
                To get you back on your feet, why don\'t you <a href="">check out 
                some awesome Spaces</a>.</p>
                </div>
                </div>
            ';
}
?>